package br.com.sca.dao;

import br.com.sca.entidades.Login;
import java.util.List;
import javax.persistence.Query;

public class LoginDAO extends DAO {

    public List<Login> logins(String login, String senha) {
        Query q = criaQuery("SELECT l FROM Login l WHERE l.ativo = true AND l.login = '"+login+"' AND l.senha = '"+senha+"'");
        return q.getResultList();
    }
    
    public List<Login> listaUsuarios() {
        Query q = criaQuery("SELECT l FROM Login l  WHERE l.ativo = true ORDER BY l.nomeCompleto");
        return q.getResultList();
    }
    public List<Login> pesquisaUsuarioPorNome(String nome) {
        Query q = criaQuery("SELECT l FROM Login l WHERE l.ativo = true AND l.nomeCompleto LIKE '%"+ nome +"%' ORDER BY l.nomeCompleto");
        return q.getResultList();
    }    
    public List<Login> pesquisaLogin(String nome) {
        Query q = criaQuery("SELECT l FROM Login l WHERE l.login = '"+ nome +"'");
        return q.getResultList();
    }    
}
